<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">对方单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="duier" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">发票号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="nums" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开票登记单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开票金额含税</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">发票类型：</label>
                        <div class="layui-input-block">
                            <select id="piaotype" name="piaotype" lay-filter="piaotype">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开票日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="dt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">经手人</label>
                        <div class="layui-input-block">
                            <input type="text" name="baner" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">审核状态：</label>
                        <div class="layui-input-block">
                            <select id="status" name="status" lay-filter="status">
                                <option value="">请选择</option>
                                <option value="1">流程（审批通过）</option>
                                <option value="0">流程（审批中）</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('{{d.kaiid}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
        <button class="layui-btn layui-btn-sm laytp-container-tool-button xuan_button" onclick="auth_but_func_she('设置计税规则')" style="padding-right: 12px;"><i class="layui-icon layui-icon-ok-circle"></i>设置计税规则</button>
    </div>
</script>
<script>

    var param_enginid = getQueryVariable('enginid') || 0;
    var param_status = getQueryVariable('status') || '';

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('开票明细');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_piao_kai_detail),where: {enginid:param_enginid,status:param_status}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                var piaotype_str = '<option value="">请选择</option>';
                var piaotype_str = res.data.piaotype;
                for (var key in piaotype){
                    if(res.data.is_piaotype == key){
                        piaotype_str += '<option value="'+key+'" selected>'+piaotype[key]+'</option>';
                    }else {
                        piaotype_str += '<option value="'+key+'">'+piaotype[key]+'</option>';
                    }

                }
                $("#piaotype").html(piaotype_str);

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'enginname', title: '项目名称'}
                ,{field: 'engin_chanid_name', title: '项目所属单位'}
                ,{field: 'nums', title: '发票号码'}
                ,{field: 'fee', title: '不含税金额(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.fee);}}
                ,{field: 'rate', title: '税率(%)'}
                ,{field: 'ratefee', title: '税额(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.ratefee);}}
                ,{field: 'listmoney', title: '价税合计(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.listmoney);}}

                ,{field: 'zengshui', title: '增值税(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.zengshui);}}
                ,{field: 'chengjian', title: '城建税(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.chengjian);}}
                ,{field: 'jiaofu', title: '教育费附加(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.jiaofu);}}
                ,{field: 'dijiao', title: '地方教育费(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.dijiao);}}
                ,{field: 'yinhua', title: '销项印花税(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.yinhua);}}
                ,{field: 'jinhua', title: '进项印花税(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.jinhua);}}
                ,{field: 'canbao', title: '残保金(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.canbao);}}
                ,{field: 'gonghui', title: '工会经费(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.gonghui);}}
                ,{field: 'shuili', title: '水利基金(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.shuili);}}
                ,{field: 'jiaopei', title: '教培费(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.jiaopei);}}
                ,{field: 'qisuo', title: '企业所得税(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.qisuo);}}
                ,{field: 'allshui', title: '税金合计(元)',align:'right',totalRow: true,templet: function(d){return parseFormatNum(d.allshui);}}

                ,{field: 'listexplain', title: '备注'}
                ,{field: 'number', title: '开票登记单号'}
                ,{field: 'piaotype', title: '发票类型'}
                ,{field: 'duier', title: '受票单位'}
                ,{field: 'dt', title: '开票日期'}
                ,{field: 'baner', title: '经手人'}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_she(buttitle){
        var checkStatus = layui.table.checkStatus('datalist').data;
        if(checkStatus.length != 1){
            facade.error(buttitle + "：请选择单条数据");return false;
        }
        openPageEdit('../piao_kai/she.php?close=1&id='+checkStatus[0].kailistid);
    }
    function auth_but_func_show(id){
        openPage('../piao_kai/show.php?id='+id);
    }

</script>
</body>
</html>
